import getCurrentColor from "~background/actions/getCurrentColor";
import {executeInCurrentTab} from "~background/utils";

const highlightText = async () => {
    console.log("inside highlightText");
    function contentScriptHighlightText(currentColor) {
        console.log("inside contentScriptHighlightText");
        if (window.top !== window.self) return; // JM：iframe调用检查
        window.highlighterAPI.highlightText.create(currentColor);
        // window.highlighterAPI.highlighterCursor.toggle();
    }

    const currentColor = await getCurrentColor();
    executeInCurrentTab({ func: contentScriptHighlightText, args: [currentColor] });
}

export default highlightText;
